package java6699.lesson11;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @program: java_zzx
 * @description:
 * @author: zzx
 * @create: 2022-11-12 15:52
 **/
public class JDBCDemo6699 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.jdbc.Driver");//加载注册驱动
        //连接数据库
        Connection conn = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/db3",
                "root","1234");
        //输出数据库名称、版本号、数据库的URL
        System.out.print("使用的数据库产品：" + conn.getMetaData().getDatabaseProductName() + "\n");
        System.out.print("版本号：" + conn.getMetaData().getDatabaseProductVersion() + "\n");
        System.out.print("数据库的URL：" + conn.getMetaData().getURL());
        conn.close();
    }
}
